package com.thitech.sif.interceptor;

import com.thitech.sif.AbsOutput;
import com.thitech.sif.SIFReturn;
import com.thitech.sif.returntype.ReturnType;
import com.thitech.sif.utils.log.LogFactory;
import com.thitech.sif.utils.log.SifLogger;

/**
 * 抽象拦截器类，因绝大多数情况下，接口中init及两个方法都不需要实现，所以使用此抽象类将这两个方法置空
 * 
 * @author shisheng.lian
 * @date 2014-04-08
 * 
 */
public abstract class AbsInterceptorHandler implements InterceptorHandler {
	private SifLogger logger = LogFactory.getLogger(getClass());

	@Override
	public void destroy() {
		// do nothing
	}

	@Override
	public void init() {
		// do nothing
	}

	public SifLogger getLogger() {
		return logger;
	}
	
	/**
	 * 更新output中的SIFReturn对象
	 * @param type
	 * @param message
	 * @param output
	 */
	public void updateSifReturn(ReturnType type, String message, AbsOutput output) {
		SIFReturn sifReturn = output.getSifReturn();
		sifReturn.setType(type.getType());
		sifReturn.setMessage(message);
	}
}
